import java.util.*;
import java.io.*;

public class CommandBuilder implements Serializable {
	
	String Command = null;
	String Target = null;
	String orientation = null;
	String place = null;
	
	public void init(String a) {
		
		ArrayList<String> Sentence = new ArrayList<String>();
		Command = null;
		Target = null;
		orientation = null;
		place = null;
		int SentenceLocation = 0;
		
		
		StringTokenizer Wordbreaker = new StringTokenizer(a);
		
		while (Wordbreaker.hasMoreTokens()) {
			Sentence.add(Wordbreaker.nextToken());
		}
		
		try {
		Command = Sentence.get(0);
		Sentence.remove(0);
		StringBuilder TargetMaker = new StringBuilder();
		StringBuilder PlaceMaker = new StringBuilder();
		
		
		
		
		for (int i = 0; i < Sentence.size(); i++) {
			
			if (Sentence.get(i).equalsIgnoreCase("in") || (Sentence.get(i).equalsIgnoreCase("on")) || (Sentence.get(i).equalsIgnoreCase("Under")) || (Sentence.get(i).equalsIgnoreCase("to")) || (Sentence.get(i).equalsIgnoreCase("Under")) || (Sentence.get(i).equalsIgnoreCase("about"))) {
				orientation = Sentence.get(i);
				SentenceLocation = i + 1;
				
				break;
			}
			
			if (Sentence.get(i).equalsIgnoreCase("the") || Sentence.get(i).equalsIgnoreCase("to")) {
			} else {
				if (TargetMaker.length() == 0) {
				TargetMaker.append(Sentence.get(i));
				} else {
					TargetMaker.append(" " + Sentence.get(i));
				}
			}
		}
		
		for (int i = SentenceLocation; i < Sentence.size(); i++) {
			
			if (Sentence.get(i).equalsIgnoreCase("the")) {
			} else {
				if (PlaceMaker.length() == 0) {
					PlaceMaker.append(Sentence.get(i));
				} else {
					PlaceMaker.append(" " + Sentence.get(i));
				}
			}
		}
	
		Target = TargetMaker.toString();
		place = PlaceMaker.toString();
		
	} catch (IndexOutOfBoundsException e) {
		Command = "do";
		Target = "Empty";
		orientation = "Empty";
		place = "Empty";
	}
	
	}
	
	public String getCommand() {
		return Command;
	}
	
	public String getTarget() {
		return Target;
	}
	
	public String getOrientation() {
		return orientation;
	}
	
	public String getPlace() {
		return place;
	}

}